Skip to content

cargo xtask improvements #1741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

cargo xtask improvements #1741

wants to merge 2 commits into from

Conversation

phip1611
Copy link
Member

Prerequisite for #1699 where I want to use

#[repr(C, align(4))]
pub struct IpAddress(pub [u8; 16]);

in uefi-raw.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

This helps to better understand why something fails.
check-raw is very strict. Relaxing it gives uefi-raw more
freedom, which is especially needed for the more high-level
IpAddress type changes.
@nicholasbishop
Copy link
Member

nicholasbishop commented Aug 15, 2025

Can you say more about why the IpAddress type needs align(4)? The current definition as a union is intentionally done that way to match edk2 and the UEFI spec. (Note that the spec briefly describes it under data types in a way that sounds like it's just a [u8; 16] buffer, but it's later fully defined in a kind of hidden spot under EFI_PXE_BASE_CODE_PROTOCOL as a union.) There are two issues with it being a [u8; 16] wrapper:

@phip1611
Copy link
Member Author

phip1611 commented Aug 15, 2025

Ah, interesting. I actually wanted to make it a struct and drop the union. If always all bytes are initialized, some things get much easier. But I didn't know the problem with packed wrappers.

Counter idea: we keep the union but make the fields private. Via a public constructor we can ensure that always all bytes are initialized, even for v4 addresses.

What do you think about this?

@nicholasbishop
Copy link
Member

I think uefi-raw is the wrong place for that abstraction, it should simply match the C API as close as possible and be public. In uefi, we should drop IpAddress and replace with core::net::IpAddr as discussed in #1575.

@phip1611
Copy link
Member Author

it should simply match the C API

While I definitely see this as perfectly fine for the majority of the code base, I believe that this may be a valid exception. Preventing undefined bytes here would be a low-hanging fruit.

I don't have a very strong opinion, but a tendency. Let me continue my "experiments" to simplify and improve the network code and then I'd leave some more comments on this.

@phip1611 phip1611 marked this pull request as draft August 16, 2025 11:27
@phip1611 phip1611 closed this Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants